<template>
  <div class="detailnavbar">
    <NavBar>
      <div class="back" slot="left" @click="back">
        <img src="~assets/img/common/back.svg"  alt="">
      </div>
      <div slot="center" class="titles">
        <div v-for="(title,index) in titles"
             :key="index" class="title"
             @click="titleClick(index)"
             :class="{active: curIndex == index}">
          {{ title }}
        </div>
      </div>
    </NavBar>
  </div>
</template>

<script>
import NavBar from "../../../components/common/navbar/NavBar";

export default {
  name: "DetailNavBar",
  data() {
    return {
      titles: ['商品', '参数', '评论', '推荐'],
      curIndex: 0
    }
  },
  components: {
    NavBar
  },
  methods: {
    titleClick(index) {
      this.curIndex = index
      this.$emit('detailNavclick',index)
    },
    back() {
      this.$router.back()
    }
  }
}
</script>

<style scoped>
.titles {
  display: flex;
  font-size: 13px;
}

.title {
  flex: 1;
}

.active {
  color: var(--color-tint);
}
.back{
  width: 100%;
  height: 100%;
}
.back img{
  margin-top: 11px;
}
</style>